﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Program24
{
    class Program
    {
        #region 需求
        //string[] names = { "abcdDE", "DEdfsEFDd", "ASFdf" };
        //三个需求：
        //将所有元素转换成大写
        //将所有元素转换成小写
        //将所有元素两边加上一个双引号
        //用委托来实现
        #endregion

        public delegate string DelProStr(string str);

        static void Main(string[] args)
        {
            string[] names = { "abcdDE", "DEdfsEFDd", "ASFdf" };

            //大写
            foreach (var item in ProString(names, Capitals))
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();
            //小写
            foreach (var item in ProString(names, LowerCase))
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();
            //加标点符号
            foreach (var item in ProString(names, AddSymbol))
            {
                Console.Write(item + " ");
            }
            Console.ReadLine();

        }

        private static string[] ProString(string[] names, DelProStr del)
        {
            for (var i = 0; i < names.Length; i++)
            {
                //传入一个处理方式
                names[i] = del(names[i]);
            }
            return names;
        }

        /// <summary>
        /// 将字符串替换成大写
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string Capitals(string str)
        {
            return str.ToUpper();
        }

        /// <summary>
        /// 将字符串替换成小写
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string LowerCase(string str)
        {
            return str.ToLower();
        }

        /// <summary>
        /// 字符串前后添加符号
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string AddSymbol(string str)
        {
            return "“" + str + "”";
        }
    }
}
